package com.ruoyi.web.controller.position;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.control.dto.RyxxNumDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.position.domain.Ryxx;
import com.ruoyi.position.service.IRyxxService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员定位-人员信息Controller
 *
 * @author hcc
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/control/ryxx")
public class RyxxController extends BaseController
{
    @Autowired
    private IRyxxService ryxxService;

    /**
     * 查询人员定位-人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ryxx ryxx)
    {
        startPage();
        List<Ryxx> list = ryxxService.selectRyxxList(ryxx);
        return getDataTable(list);
    }
    /**
     * 查询人员定位-人员数量
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:list')")
    @GetMapping("/listNum")
    public RyxxNumDto listNum(Ryxx ryxx)
    {
        RyxxNumDto dto = ryxxService.selectRyxxListNum(ryxx);
        return dto;
    }
    /**
     * 查询人员定位-人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:list')")
    @GetMapping("/getList")
    public List<Ryxx> getList()
    {
        List<Ryxx> list = ryxxService.getList();
        return list;
    }

    /**
     * 导出人员定位-人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:export')")
    @Log(title = "人员定位-人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Ryxx ryxx)
    {
        List<Ryxx> list = ryxxService.selectRyxxList(ryxx);
        ExcelUtil<Ryxx> util = new ExcelUtil<Ryxx>(Ryxx.class);
        util.exportExcel(response, list, "人员定位-人员信息数据");
    }

    /**
     * 获取人员定位-人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:query')")
    @GetMapping(value = "/{personId}")
    public AjaxResult getInfo(@PathVariable("personId") String personId)
    {
        return success(ryxxService.selectRyxxByPersonId(personId));
    }

    /**
     * 新增人员定位-人员信息
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:add')")
    @Log(title = "人员定位-人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ryxx ryxx)
    {
        return toAjax(ryxxService.insertRyxx(ryxx));
    }

    /**
     * 修改人员定位-人员信息
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:edit')")
    @Log(title = "人员定位-人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ryxx ryxx)
    {
        return toAjax(ryxxService.updateRyxx(ryxx));
    }

    /**
     * 删除人员定位-人员信息
     */
    @PreAuthorize("@ss.hasPermi('control:ryxx:remove')")
    @Log(title = "人员定位-人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{personIds}")
    public AjaxResult remove(@PathVariable String[] personIds)
    {
        return toAjax(ryxxService.deleteRyxxByPersonIds(personIds));
    }
}
